package Controllers;

import Entities.UserMessages;
import Facades.UserMessagesFacade;
import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.inject.Inject;

@ManagedBean(name = "userMessagesController")
@ViewScoped
public class UserMessagesController extends AbstractController<UserMessages> implements Serializable {

    @Inject
    private UserMessagesFacade ejbFacade;

    public UserMessagesController() {
        super(UserMessages.class);
    }

    @PostConstruct
    public void init() {
        super.setFacade(ejbFacade);
    }

    @Override
    protected void setEmbeddableKeys() {
        this.getSelected().getUserMessagesPK().setMessageIdmessage(this.getSelected().getMessage().getIdMessage());
        this.getSelected().getUserMessagesPK().setUserId(this.getSelected().getUserid().getId());
    }

    @Override
    protected void initializeEmbeddableKey() {
        this.getSelected().setUserMessagesPK(new Entities.UserMessagesPK());
    }
}
